﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Interfaz_V1
{
    public partial class MessageForm : Form
    {
        public int resp;
        public String txt;

        public MessageForm()
        {
            InitializeComponent();
            resp = -1;
        }

        public MessageForm(String txt)
        {
            InitializeComponent();
            resp = -1;
            this.txt = txt;
        }

        private void MessageForm_Load(object sender, EventArgs e)
        {
            this.Text = txt;
        }

        public void setItems(string[] newItems)
        {
            comboPorts.Items.Clear();

            foreach (string item in newItems)
            {
                comboPorts.Items.Add(item);
            }

        }

        private void buttonConnect_Click(object sender, EventArgs e)
        {


            resp = comboPorts.SelectedIndex;
            this.Close();

        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {

            resp = -1;
            this.Close();

        }

        private void comboPorts_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                buttonConnect_Click(sender, e);
        }

    }
}
